package com.ciko.code.utils;

import android.content.Context;
import android.util.DisplayMetrics;


/**
 * 屏幕信息类
 * 
 * @author daizhipeng
 */
public class ScreenUtil
{
	public static int   screenWidth;
	public static int   screenHeight;
	public static float density;
	public static float scaleDensity;
	public static float xdpi;
	public static float ydpi;
	public static int   densityDpi;
	public static int   screenMin;   // 宽高中，最小的值
	                                  
	public static void GetInfo(Context context) {
		if (null == context) { return; }
		DisplayMetrics dm = new DisplayMetrics();
		dm = context.getApplicationContext().getResources().getDisplayMetrics();
		screenWidth = dm.widthPixels;
		screenHeight = dm.heightPixels;
		screenMin = (screenWidth > screenHeight) ? screenHeight : screenWidth;
		density = dm.density;
		scaleDensity = dm.scaledDensity;
		xdpi = dm.xdpi;
		ydpi = dm.ydpi;
		densityDpi = dm.densityDpi;
	}
	
	/**
	 * dip转px
	 * 
	 * @param context
	 * @param dipValue
	 * @return
	 */
	public static int dip2px(float dipValue) {
		final float scale = ScreenUtil.density;
		return (int) (dipValue * scale + 0.5f);
	}
	
	public static boolean isBigScreen() {
		return screenWidth > 720 ? true : false;
	}
	
}
